<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String contextPath = application.getContextPath();
	pageContext.setAttribute("path", contextPath);
%>
<!DOCTYPE HTML>
<html>
<head>
<jsp:include page="common_header.jsp" flush="true"></jsp:include>
<title>用户查看</title>
</head>
<body>
<div class="pd-20">
  <article class="page-container">
	<form class="form form-horizontal" id="form-admin-add">
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="" id="username" name="username">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"></span>姓名：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="" name="fullName">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"></span>性别：</label>
		<div class="formControls col-xs-8 col-sm-9 skin-minimal">
			<div class="radio-box">
				<input name="gender" type="radio" value="1" id="sex-1" checked>
				<label for="sex-1">男</label>
			</div>
			<div class="radio-box">
				<input type="radio" id="sex-2" value="0" name="gender">
				<label for="sex-2">女</label>
			</div>
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="" id="phone" name="phone">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" placeholder="@" name="email" id="email">
		</div>
	</div>
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;修改&nbsp;&nbsp;">
		</div>
	</div>
	</form>
</article>
</div>
<jsp:include page="_footer.jsp" flush="true"></jsp:include>
<script>

$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	
	
	$("#form-admin-add").validate({
		rules:{
			username:{
				required:true,
				minlength:3,
				maxlength:30
			},
			fullName:{
				required:false,
				minlength:1,
				maxlength:50
			},
			phone:{
				required:true,
				isPhone:true
			},
			email:{
				required:true,
				email:true,
				maxlength:50
			}
		},
		success:"valid",
		submitHandler:function(form){
			updateUser();
		}
	});
});

function fillData(){
	jajax({
		url: "${path}/user/currentUserInfo.do",
		success: function(data, textStatus){
			var obj = data.data;
			
			fillFormByName('form-admin-add', obj);
			$('.skin-minimal input').iCheck({
				checkboxClass: 'icheckbox-blue',
				radioClass: 'iradio-blue',
				increaseArea: '20%'
			});
		}
	});
}

function updateUser(){
	var formData = $('#form-admin-add').serialize();
	jajax({
		url: '${path}/user/updateCurrentUserInfo.do',
		data: formData, 
		type: "post",
		success: function(data, textStatus){
			layer.msg('成功!',{icon:1,time:1000});
		}
	});	
	
}
</script>
</body>
</html>
